package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;

public class Demo3 {
    public static void main(String[] args) throws IOException {
        /*FileInputStream fis = new FileInputStream("a.txt");
        int read = fis.read();
        System.out.println(read);
        read = fis.read();
        System.out.println(read);
        read = fis.read();
        System.out.println(read);
        read = fis.read();
        System.out.println(read);
        read = fis.read();
        System.out.println(read);
        read = fis.read();
        System.out.println(read);
        fis.close();*/
        FileInputStream fis = new FileInputStream("a.txt");
        /*int len=0;
        while((len = fis.read()) != -1){
            System.out.println((char)len);
        }*/
        /*byte[] bytes = new byte[2];
        int read = fis.read(bytes);
        System.out.println(read);
        System.out.println(new String(bytes));
        read = fis.read(bytes);
        System.out.println(read);
        System.out.println(new String(bytes));
        read = fis.read(bytes);
        System.out.println(read);
        System.out.println(new String(bytes));
        read = fis.read(bytes);
        System.out.println(read);
        System.out.println(new String(bytes));*/
        byte[] bytes = new byte[1024];
        int len = 0;
        while ((len = fis.read(bytes)) != -1) {
            System.out.println(len);
            System.out.println(new String(bytes,0,len));

        }
        fis.close();
    }
}
